<template>
<div class="wrapper">
        <h2>数组式Tab切换</h2>
        <div class="shape">
            <h3>效果展示</h3>
            <div>
                <TabArray :val="val"></TabArray> 
            </div>
        </div>
       
        <div class="markdown-body">
            <pre><code>{{
`<!-- 接受一个数组val-->
<!-- 默认会对数组title自动去重 -->
<TabArray :val="val"></TabArray> `
                }}</code></pre>
        </div>
        <div class="shape">
            <h3 @click="getCode">查看源码</h3>
            <main class="markdown-body" v-show="code">
<pre><code>{{
`<template>
    <TabArray :val="val"></TabArray>
</template>

<script lang="ts">
import TabArray from '../lib/TabArray.vue'

export default {
    components:{TabArray},
    setup(){
        const val=[
            {title:'导航1',content:'内容1'},
            {title:'导航2',content:'内容2'},
            {title:'导航2',content:'内容2'},
        ]
        // 只需传递数组，可自动对title去重
        return {val}  
    }        
}
</script>`
}}</code></pre>
            </main>
        </div>
    </div> 
</template>

<script lang="ts">
import TabArray from '../lib/TabArray.vue'
import {ref} from "vue"

export default {
    components:{TabArray},
    setup(){
        const val=[
            {title:'导航1',content:'内容1'},
            {title:'导航2',content:'内容2'},
            {title:'导航2',content:'内容2'},
        ]
        const code=ref(false)
        const getCode=()=>{
                code.value=!code.value
        }
        return {code,getCode,val}  
    }        
}
</script>

<style lang="scss" scoped>
.wrapper{
    max-width:800px;
    h2{
        padding-bottom: 30px;
        border-bottom: 1px solid rgb(212, 208, 208);
    }
    .shape{
        margin:30px 0px;
        >h3{
            margin-bottom: 10px;
        }
        >div{
            display: flex;
            padding: 50px;
            align-items: center;
            justify-content: center;
            border:1px solid rgb(212, 208, 208);
        }
    }
}
</style>